/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ac.persistence;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.IOException;
import java.io.Reader;

/**
 * Clase singleton para crear objetos de tipo SqlMapClient
 *
 * @author prometheus
 */
public class SqlConnector {

    private static SqlConnector instance = new SqlConnector();

    /**
     * Clase Castrada, Patrón de Diseño SINGLETON
     */
    private SqlConnector () { }

    /**
     * Construye el recurso SqlMap
     * @return el recurso SqlMap listo para ser utilizado
     * @throws java.io.IOException
     */
    public SqlMapClient getReady () throws IOException {
        Reader reader = Resources.getResourceAsReader("ac/conf/SqlMapConfig.xml");
        SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
        return sqlMap;
    }

    public static SqlConnector getInstance () {
        return SqlConnector.instance;
    }


}
